1 <?
2 if
(isset($_POST['butSaveLoai'])) {
3     $donvi = trim($_POST[
'txtName']);
4     $parent = $_POST[
'txtParent'];
5
6     
if ($donvi=="")
7     {
8         echo
"<p align=center class='err'>B&#7841;n ch&#432;a nh&#7853;p tên &#273;&#417;n v&#7883;</p>";
9     }
10     
else
11     {
12         
if (!empty($_POST['oldid'])) {
13             $oldid = $_POST[
'oldid'];
14             $sql =
"update donvi set dv_name='".$donvi."',parent_id='".$parent."' where dv_id='".$oldid."'";
15         }
16         
else
17             $sql =
"insert into donvi (dv_name,parent_id) values ('".$donvi."','".$parent."')";
18         
if (mysql_query($sql,$con)) {
19             echo
"<p align=center class='err'>&#272;ã c&#7853;p nh&#7853;t thành công</p><br>";
20             echo
"<script>window.location='index.php?act=donvi_id&page=".$_REQUEST['page']."'</script>";
21         }
22         
else echo "<p align=center class='err'>Không th&#7875; c&#7853;p nh&#7853;t</p>";
23     }
24 }
25 ?>
26
27 <?
28     
if (isset($_GET['id'])) {
29         $oldid=$_GET[
'id'];
30         $sql =
"select * from donvi where dv_id='".$oldid."'";
31         
if ($result = mysql_query($sql,$con)) {
32             $row=mysql_fetch_array($result);
33             $donvi=$row[
'dv_name'];
34             $parent=$row[
'parent_id'];
35         }
36     }
37 ?>
38
39 <form method=
"POST" name="FormLoaiSP" action="index.php">
40 <input type=hidden name=
"act" value="donvi_id_m">
41 <input type=hidden name=
"oldid" value="<? echo $oldid; ?>">
42 <input type=hidden name=
"page" value="<? echo $_REQUEST['page']; ?>">
43 <table border=
"1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
44   <tr>
45     <td width=
"45%" align="center" class="title" height="20">Thêm m&#7899;i / C&#7853;p nh&#7853;t :
46     &#
272;&#417;n v&#7883;</td>
47   </tr>
48   <tr>
49     <td width=
"45%">
50     <table border=
"0" cellpadding="4" bordercolor="#111111" width="100%" id="AutoNumber2" cellspacing="0">
51       <tr>
52         <td width=
"15%" class="smallfont">
53         <p align=
"right">&#272;&#417;n v&#7883;</td>
54         <td width=
"1%" class="smallfont">
55         <font color=
"#FF0000">*</font></td>
56         <td width=
"83%" class="smallfont">
57         <INPUT
value="<? echo $donvi; ?>" TYPE="text" NAME="txtName" CLASS=textbox size="34"></td>
58       </tr>
59             <tr>
60         <td width=
"15%" class="smallfont">
61         <p align=
"right">Thu&#7897;c danh m&#7909;c</td>
62         <td width=
"1%" class="smallfont">
63         &nbsp;</td>
64         <td width=
"83%" class="smallfont">
65         <
select size="1" name="txtParent">
66     <?
67         
//echo "<option value='0'>[Danh m&#7909;c g&#7889;c]</option>";
68         $cats=GetListDonvi(
"","=");
69         
foreach ($cats as $cat)
70         {
71             
if ($cat[0]==$parent)
72                 echo
"<option value=".$cat[0]." selected>".$cat[1]."</option>";
73             
else
74                 echo
"<option value=".$cat[0].">".$cat[1]."</option>";
75         }
76     ?>
77         </
select>
78         
79 </td>
80       </tr>
81
82       <tr>
83         <td width=
"15%" class="smallfont">
84         <p align=
"right">
85         <INPUT TYPE=
"submit" NAME="butSaveLoai" VALUE="C&#7853;p nh&#7853;t" CLASS=button>&nbsp;</td>
86         <td width=
"1%" class="smallfont">
87         &nbsp;</td>
88         <td width=
"83%" class="smallfont"><p align="left">&nbsp;<INPUT TYPE="reset" CLASS=button value="Nh&#7853;p l&#7841;i"></td>
89       </tr>
90     </table>
91     </td>
92   </tr>
93   </table>
94 </form>



Full source code website bán hàng thương mại điện tử gần giống shopee 468.816 lượt xem

Gõ tìm kiếm nhanh...